package com.example.wac.vo;

import lombok.Data;

/**
 * @author wuancheng
 * @description
 * @date 2021-12-30 18:02:00
 */

@Data
public class ApiResult {
    /**
     * 状态码
     */
    private Boolean flag;
    /**
     * 错误码
     */
    private String errorCode;
    /**
     * 错误描述
     */
    private String errorDesc;
    /**
     * 数据
     */
    private Object data;

    public ApiResult(Boolean flag, String errorCode, String errorDesc, Object data) {
        this.flag = flag;
        this.errorCode = errorCode;
        this.errorDesc = errorDesc;
        this.data = data;
    }

    public static ApiResult success(){
        return new ApiResult(true,null,null,null);
    }

    public static ApiResult success(Object data){
        return new ApiResult(true,null,null,data);
    }

    public static ApiResult error(String errorCode, String errorDesc){
        return new ApiResult(false,errorCode,errorDesc,null);
    }

    public static ApiResult error(String errorCode, String errorDesc, Object data){
        return new ApiResult(false,errorCode,errorDesc,data);
    }
}
